diff options
author | waker <wakeroid@gmail.com> | 2011-01-10 20:31:54 +0100 |
---|---|---|
committer | waker <wakeroid@gmail.com> | 2011-01-10 21:02:40 +0100 |
commit | bad68f332469178ffb81a0dd2ac74ae62301af72 (patch) | |
tree | c6b2d0387a145511d12198e9035368cb8b178f3b /plugins/alsa | |
parent | 822c99debf259c6648654143abc9d772ea447f73 (diff) |
fixed resume in paused state;
changed output plugin setformat method to return error code
changed setformat to restore state before the call
Diffstat (limited to 'plugins/alsa')
-rw-r--r-- | plugins/alsa/alsa.c | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/plugins/alsa/alsa.c b/plugins/alsa/alsa.c index 7a4d12ef..d76d821f 100644 --- a/plugins/alsa/alsa.c +++ b/plugins/alsa/alsa.c @@ -88,7 +88,7 @@ palsa_init (void); static int palsa_free (void); -static void +static int palsa_setformat (ddb_waveformat_t *fmt); static int @@ -403,16 +403,16 @@ open_error: return -1; } -void +int palsa_setformat (ddb_waveformat_t *fmt) { memcpy (&requested_fmt, fmt, sizeof (ddb_waveformat_t)); trace ("palsa_setformat %dbit %s %dch %dHz channelmask=%X\n", fmt->bps, fmt->is_float ? "float" : "int", fmt->channels, fmt->samplerate, fmt->channelmask); if (!audio) { - return; + return -1; } if (!memcmp (fmt, &plugin.fmt, sizeof (ddb_waveformat_t))) { trace ("palsa_setformat ignored\n"); - return; + return 0; } #if 0 else { @@ -432,16 +432,33 @@ palsa_setformat (ddb_waveformat_t *fmt) { ); } #endif - state = OUTPUT_STATE_STOPPED; LOCK; + int s = state; + state = OUTPUT_STATE_STOPPED; snd_pcm_drop (audio); int ret = palsa_set_hw_params (fmt); UNLOCK; if (ret < 0) { trace ("palsa_change_rate: impossible to set requested format\n"); - return; + return -1; } trace ("new format %dbit %s %dch %dHz channelmask=%X\n", plugin.fmt.bps, plugin.fmt.is_float ? "float" : "int", plugin.fmt.channels, plugin.fmt.samplerate, plugin.fmt.channelmask); + + switch (s) { + case OUTPUT_STATE_STOPPED: + return palsa_stop (); + case OUTPUT_STATE_PLAYING: + return palsa_play (); + case OUTPUT_STATE_PAUSED: + if (0 != palsa_play ()) { + return -1; + } + if (0 != palsa_pause ()) { + return -1; + } + break; + } + return 0; } int |