~diwic/ubuntu/lucid/pulseaudio/bugfixes

« back to all changes in this revision

Viewing changes to src/pulsecore/sink.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel T Chen
  • Date: 2007-12-04 00:56:08 UTC
  • mto: (1.15.1 sid)
  • mto: This revision was merged to the branch mainline in revision 15.
  • Revision ID: james.westby@ubuntu.com-20071204005608-3lzrrrpxi186kgx4
Tags: upstream-0.9.8
ImportĀ upstreamĀ versionĀ 0.9.8

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* $Id: sink.c 1971 2007-10-28 19:13:50Z lennart $ */
 
1
/* $Id: sink.c 2067 2007-11-21 01:30:40Z lennart $ */
2
2
 
3
3
/***
4
4
  This file is part of PulseAudio.
149
149
 
150
150
static int sink_set_state(pa_sink *s, pa_sink_state_t state) {
151
151
    int ret;
 
152
    pa_bool_t suspend_change;
152
153
 
153
154
    pa_assert(s);
154
155
 
155
156
    if (s->state == state)
156
157
        return 0;
157
158
 
158
 
    if ((s->state == PA_SINK_SUSPENDED && PA_SINK_OPENED(state)) ||
159
 
        (PA_SINK_OPENED(s->state) && state == PA_SINK_SUSPENDED)) {
 
159
    suspend_change =
 
160
        (s->state == PA_SINK_SUSPENDED && PA_SINK_OPENED(state)) ||
 
161
        (PA_SINK_OPENED(s->state) && state == PA_SINK_SUSPENDED);
 
162
 
 
163
    if (s->set_state)
 
164
        if ((ret = s->set_state(s, state)) < 0)
 
165
            return -1;
 
166
 
 
167
    if (pa_asyncmsgq_send(s->asyncmsgq, PA_MSGOBJECT(s), PA_SINK_MESSAGE_SET_STATE, PA_UINT_TO_PTR(state), 0, NULL) < 0)
 
168
        return -1;
 
169
 
 
170
    s->state = state;
 
171
 
 
172
    if (suspend_change) {
160
173
        pa_sink_input *i;
161
174
        uint32_t idx;
162
175
 
167
180
                i->suspend(i, state == PA_SINK_SUSPENDED);
168
181
    }
169
182
 
170
 
    if (s->set_state)
171
 
        if ((ret = s->set_state(s, state)) < 0)
172
 
            return -1;
173
 
 
174
 
    if (pa_asyncmsgq_send(s->asyncmsgq, PA_MSGOBJECT(s), PA_SINK_MESSAGE_SET_STATE, PA_UINT_TO_PTR(state), 0, NULL) < 0)
175
 
        return -1;
176
 
 
177
 
    s->state = state;
178
 
 
179
183
    if (state != PA_SINK_UNLINKED) /* if we enter UNLINKED state pa_sink_unlink() will fire the apropriate events */
180
184
        pa_hook_fire(&s->core->hooks[PA_CORE_HOOK_SINK_STATE_CHANGED], s);
 
185
 
181
186
    return 0;
182
187
}
183
188